<?php
/**
*	链接信呼api的
*/
namespace Rainrock\Framework\Chajian;


use Rainrock\Framework\kernel\core\Chajian;
use Rainrock\Framework\kernel\base\Base;
use Rainrock\Framework\kernel\base\Jiami;


class xinhuapiChajian extends Chajian{
	
	private $apiurl = '';
	
	
	protected function initChajian() 
	{ 
		$this->apiurl = Base::getConfig('xinhuapi_url'); 
		if(!$this->apiurl)$this->apiurl = Jiami::base64decode('aHR0cDovL2FwaS5yb2Nrb2EuY29tLw::');
	}

	public function geturl($m, $a, $can=array())
	{
		$url = $this->apiurl.'?m='.$m.'&a='.$a.'';
		foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
		return $url;
	}
	
	/**
	*	获取数据
	*/
	public function getdata($m, $a, $can=array())
	{
		$url 	= $this->geturl($m, $a, $can);
		$curl 	= $this->c('curl');
		$result = $curl->getcurl($url);
		return $curl->result($result);
	}
	
	/**
	*	post获取数据
	*/
	public function postdata($m, $a, $data, $can=array())
	{
		$url 	= $this->geturl($m, $a, $can);
		$curl 	= $this->c('curl');
		$result = $curl->postcurl($url, $data);
		return $curl->result($result);
	}
}